/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 62536
 * Date: 2023-10-28
 * Time: 9:28
 */
public class Test {

    //打印1-100中9出现的次数
    public static void main5(String[] args) {
        int n = 0;
        for (int i = 1; i < 101; i++) {
            int j = i;
            while(j != 0){
                if(j % 10 == 9){
                    n++;
                }
                j /= 10;
            }
        }
        System.out.println(n);
    }


    //打印1000-2000的闰年
    public static void main4(String[] args) {
        int flag = 0;
        for (int i = 1000; i < 2001; i++) {
            if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) {
                System.out.print(i + " ");
                if (++flag % 20 == 0) {
                    System.out.print("\n");
                }
            }
        }
    }

    //打印1-100的素数
    public static void main3(String[] args) {
        for (int i = 2; i < 101; i++) {
            int flag = 0;
            for (int j = 2; j < i; j++) {
                if(i % j == 0){
                    flag = 1;
                    break;
                }
            }
            if(flag == 0){
                System.out.print(i +" ");
            }
        }
    }

    //判断素数
    public static void main2(String[] args) {
        int n = 24;
        int flag = 0;
        for (int i = 2; i < n; i++) {
            if(n % i == 0){
                flag = 1;
                break;
            }
        }
        if(flag == 1){
            System.out.println(n +" 不是素数");
        }else{
            System.out.println(n +" 是素数");

        }
    }
}
